<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>成功</title>
    <link rel="stylesheet" href="__ADMINS__admin/css/other/result.css" />
</head>

<body>
<div class="pear-container">
    <div class="layui-card">
        <div class="layui-card-body">

            <div class="pear-result">
                {if(!empty($data))}
                <div class="success">
                    <img src="{$data['img']}" alt="" style="width: 300px;height: 300px">
                </div>
                <h2 class="title">谷歌令牌绑定</h2>
                <p class="description">使用Google Authenticator扫码绑定。或通过串码链接</p>
                <p class="description" style="color: red;font-size: 25px;">{$data['secret']}</p>
                    <div class="layui-form layui-margin-4">
                        <input type="hidden" name="google_secret" value="{$data['secret']}" id="google_secret">
                        <div class="layui-form-item">
                            <label class="layui-form-label">验证绑定</label>
                            <div class="layui-input-block">
                                <input type="number" name="google_code" lay-verify="required|number" placeholder="请输入6位数字验证码" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
                            </div>
                        </div>
                    </div>
                {else/}
                <p class="description" style="color: red;font-size: 50px;height: 20vh;">您已绑定成功！</p>
                {/if}
            </div>

        </div>
    </div>
</div>
<script>
    layui.use(['form', 'popup','toast'], function(){
        var $ = layui.jquery;
        var form = layui.form;
        var toast = layui.toast;
        var popup = layui.popup;

        // 提交事件
        form.on('submit(demo1)', function(data){
            var field = data.field; // 获取表单字段值
            $.post('{:url($operate.update)}',field,function(res){
                if(res.code === 200){
                    popup.success(res.msg, function () {
                        PearAdmin.refresh();
                    });
                }else{
                    toast.error({
                        message: res.msg,
                    });
                    $("#v_code_img").click();
                }
            })
            return false; // 阻止默认 form 跳转
        });
    });
</script>
</body>

</html>